<nav class="clearfix">
	<div class="left lfoat">
          <img src="../img/logo2.png" style="width: 168px;"/>
	</div>
	<div class="right">
		<div class="login  rfoat">
			<a href="javascript:;" id="changePass">
				<div class="txHead lfoat">
					<i class="glyphicon glyphicon-user"></i>
				</div>
			</a>
			<p class="lfoat">欢迎管理员:<span id="id"></span></p>
			<a href="###" id="logOut">退出</a>
		</div>
	</div>
	<div id="mask">
		<div id="alertChangePass" class="alert">
			<div class="title">修改密码<span id="close"><i class="glyphicon glyphicon-remove"></i></span></div>
			<input type="password" placeholder="原密码" id="password"/>
			<input type="password" placeholder="新密码" id="newPassword"/>
			<input type="password" placeholder="确认密码" id="newPassword2"/>
			<button type="button" class="btn btn-primary" id="sure">确定</button>

		</div>
	</div>
</nav>

<script>
	$("#id").html(sessionStorage.getItem("id"));
	wh();
	function wh() {
	     $("#mask").height($(window).height());
	}
	
	$(window).resize(function(){
       wh();
    });
    $("#changePass").click(function(){
    	$("#mask").show();
    })
    $("#close").click(function(){
    	$("#mask").hide();
    })
    
    //修改密码
    $("#sure").click(function(){
    	if($('#password').val()=="" || $('#newPassword').val()=="" || $('#newPassword2').val()==""){
    		prompt("密码不能为空！");
    	}
    	else if($('#newPassword').val() != $('#newPassword2').val()){
    		prompt("确认密码错误！");
    	}else{
    		$.ajax({
				type: "put",
				url: "/wechat_mt5/admin/update/password",

				data: {
					password: $('#password').val(),
					newPassword: $('#newPassword').val(),

				},
				success: function(data) {
                       if (data.code==0) {
                       	   window.location.href = "../index.html";
                       }else{
                       	  if(data.code=10040001){
                       	  	prompt("原密码错误")
                       	  }
                       }
				}

			})
    	}
    	
    })
    
    //退出登录
    $("#logOut").click(function(){
    	$.ajax({
				type: "get",
				url: "/wechat_mt5/admin/logout",
				success: function(data) {
                       if (data.code==0) {
                       	   window.location.href = "../index.html";
                       	   sessionStorage.getItem("id",null);
                       }
				}

			})
    })
    
    
    
</script>